<template>
	<view class="content">
		<view class="padding-about-30 padding-top-01">
			<view class="view display-flex margin-top-20" v-for="item,index in list" :key="index">

				<view class="margin-left-20 display-flex flex-direction-column space-between file-1">
					<view class="">
						<view class="font-size-28 webkit-line-clamp" style="-webkit-line-clamp: 1;">
							编号：{{item.card_num}}
						</view>
						<view class=" font-size-26 color-999 webkit-line-clamp" style="-webkit-line-clamp: 2;">
							操作日期：{{ timestampToDate(item.updatetime * 1000,'Y-m-d')}}
						</view>
					</view>
				</view>
				<view class="  display-flex flex-direction-column margin-left-20 space-around">
					<view @click="navigateTo('/pages/show/editcard/editcard?id=' + item.id)"
						style="background: #2671CE;" class="button">
						继续操作
					</view>
					<view @click="del(item.id)" style="background: #FF7700;" class="button margin-top-10">
						删除草稿
					</view>
				</view>
			</view>
			<view class="kong">

			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from 'vue';
	import {
		onLoad,
		onShow,
		onReady,
		onReachBottom
	} from '@dcloudio/uni-app';
	import {
		nativeUI,
		navigateTo,
		navigateBack,
		timestampToDate
	} from '@/utils/index.js';
	import * as api from '@/request/app.js'; // 引入api 方法
	import local from '@/utils/localStorage.js'; //引入本地存储方法
	//分页
	const pagingState = ref(false)
	const page = ref(1)
	const list = ref([])
	onLoad(function(option) {
		open_card_log()
	});
	onShow(function() {});

	function del(id) {
		uni.showModal({
			title: '提示',
			content: '您确定要删除此草稿吗？',
			success: async function(res) {
				if (res.confirm) {
					const {
						code,
						data
					} = await api.open_card_log_del({
						id
					})
					if (code == 1) {
						pagingState.value = false
						page.value = 1
						list.value = []
						open_card_log()
					}
				} else if (res.cancel) {
					console.log('用户点击取消');
				}
			}
		});

	}
	async function open_card_log() {
		if (!pagingState.value) {
			const {
				code,
				data
			} = await api.open_card_log({
				page: page.value,
				status: 0
			})
			list.value = list.value.concat(data.data)
			if (data.current_page == data.last_page) {
				pagingState.value = true
				return
			}
			page.value++
		}
	}
	onReady(function() {});
	onReachBottom(function() {
		open_card_log()
	});
</script>

<style scoped lang="scss">
	.button {
		width: 134rpx;
		height: 46rpx;
		color: #FFFFFF;
		border-radius: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 20rpx;
	}

	.view {
		padding: 15rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
	}
</style>